#include "aboutdialog.h"
#include"permissiondialog.h"
#include<QLayout>
#include<QPushButton>
#include<QLabel>
#include<QGraphicsView>
#include<QGraphicsScene>

AboutDialog::AboutDialog(QWidget *parent)
    :QDialog(parent)
{
    ButtonOK = new QPushButton(tr("OK"),this);
    ButtonPermission = new QPushButton(tr("Permission"),this);
    ButtonSourceCode = new QPushButton(tr("Source Code"),this);

    ButtonLayout = new QHBoxLayout();
    ButtonLayout->addWidget(ButtonSourceCode);
    ButtonLayout->addWidget(ButtonPermission);
    ButtonLayout->addWidget(ButtonOK);

    MapLeft = new QGraphicsView(this);
    MapLeft->setFixedSize(200,200);
    MapRight = new QGraphicsView(this);
    MapRight->setFixedSize(200,200);
    MapLayout = new QHBoxLayout();

    SceneLeft = new QGraphicsScene();
    QPixmap Slz(":/Icons/desktop.png");
    SceneLeft->addPixmap(Slz.scaled(195,195,Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
    MapLeft->setScene(SceneLeft);

    SceneRight = new QGraphicsScene();
    QPixmap AboutQt(":/Icons/qt.png");
    SceneRight->addPixmap(AboutQt.scaled(195,195,Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
    MapRight->setScene(SceneRight);

    MapLayout->addWidget(MapLeft);
    MapLayout->addStretch();
    MapLayout->addWidget(MapRight);

    Line1 = new QLabel(this);
    Line2 = new QLabel(this);
    Line3 = new QLabel(this);

    Line1->setAlignment(Qt::AlignHCenter);
    Line2->setAlignment(Qt::AlignHCenter);
    Line3->setAlignment(Qt::AlignHCenter);

    Line1->setText(tr("SLZmusic is a music player developed by"));
    Line2->setText(tr("Sui Shicong,Li Tian,Zhao ZhenLong"));
    Line3->setText(tr("But or suggest please send to berlinudberlinud@gmail.com"));

    LabelLayout = new QVBoxLayout();
    LabelLayout->addWidget(Line1);
    LabelLayout->addWidget(Line2);
    LabelLayout->addWidget(Line3);

    Layout = new QVBoxLayout(this);
    Layout->addLayout(MapLayout);
    Layout->addLayout(LabelLayout);
    Layout->addLayout(ButtonLayout);

    connect(ButtonPermission,SIGNAL(clicked()),this,SLOT(PermissionSlot()));

    setFixedSize(480,480);
}

void AboutDialog::PermissionSlot()
{
    PermissionDialog *PD = new PermissionDialog(this);
    PD->show();
}
